'''
@Author: your name
@Date: 2020-02-02 21:14:46
@LastEditTime : 2020-02-03 12:12:09
@LastEditors  : Please set LastEditors
@Description: In User Settings Edit
@FilePath: \pyqt5\demo_018_qss.py
'''
from PyQt5.Qt import *


class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('demo_018_qss')
        self.resize(500, 500)
        self.setup_ui()

    def setup_ui(self):
        self.qss_test()

    # qss stylesheet test : just for label
    def qss_test(self):
        # ---------------QSS_test-------------------begin--
        with open('demo_018_qss.qss') as file_qss:
            comment = file_qss.read()
            qApp.setStyleSheet(comment)
            
        label_1 = QLabel(self)
        # match qss id 选择器
        label_1.setObjectName('notice')
        label_1.setText('hello world')

        label_2 = QLabel(self)
        label_2.setObjectName('notice')
        label_2.setProperty('notice_level','error')
        #label_2.setProperty('notice_level','normal')
        #label_2.setProperty('notice_level','warning')
        label_2.setText('I love you,yun yun')
        label_2.move(100,100)

        btn_1 = QPushButton(self)
        btn_1.setObjectName('notice')
        btn_1.setText('this is a pushbutton')
        btn_1.move(50,50)
        # ---------------QSS_test-------------------end----


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)

    win = Window()
    win.show()
    sys.exit(app.exec_())
